<?php

class Kd_Web_Session {

    private $_abort = FALSE;

    public function __construct() {

    }

    public function remove($key) {
        if (array_key_exists($key, $_SESSION)) {
            unset($_SESSION[$key]);
        }
        return $this;
    }
    
    public function pop($key){
    	$result = $this->get($key);
    	$this->remove($key);
    	return $result;
    }

    public function has($key) {
        return isset($_SESSION[$key]);
    }

    public function get($key, $default = '') {
        if (!isset($_SESSION[$key])) {
            return $default;
        }
        return $_SESSION[$key];
    }

    public function set($key, $value) {
        $_SESSION[$key] = $value;
        return $this;
    }

    public function clear() {
        session_unset();
        return $this;
    }

    public function getId() {
        return session_id();
    }

    public function start() {
        session_start();
        return $this;
    }

    public function abort() {
        $this->_abort = TRUE;
        @session_destroy();
        return $this;
    }

}